// 用户表
const { DataTypes } = require("sequelize");
const sequelize = require("../database/db");

// 数据类型 https://www.sequelize.com.cn/core-concepts/model-basics#%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B
const User = sequelize.define(
  "t_admin_user",
  {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    name: {
      type: DataTypes.STRING,
      allowNull: true,
      defaultValue: "",
      comment: "用户姓名",
    },
    phone: {
      type: DataTypes.BIGINT(11),
      comment: "用户手机号",
    },
    password: {
      type: DataTypes.STRING,
      allowNull: true,
      defaultValue: "",
      comment: "用户密码",
    },
    avatar: {
      type: DataTypes.STRING,
      allowNull: true,
      defaultValue: "",
      comment: "用户头像",
    },
    gender: {
      type: DataTypes.INTEGER,
      comment: "性别: 1男 2女",
    },
    role: {
      type: DataTypes.BIGINT,
      comment: "权限：0超级管理员 1管理员 2普通员工",
    },
    status: {
      type: DataTypes.BIGINT,
      defaultValue: 1,
      comment: "状态 1:启用 0: 关闭",
    },
    remard: {
      type: DataTypes.STRING,
      allowNull: true,
      defaultValue: "",
      comment: "备注",
    },
  },
  {
    timestamps: true, // 自动生成 createdAt 和 updatedAt
  }
);

module.exports = User;
